package camid.services.nodemanager.observers;

import camid.distribution.events.LifecycleEvent;
import camid.distribution.lifecycle.LifecycleOperation;
import camid.services.nodemanager.NodeManager;

public class LifecycleObserver extends AbstractNodeObserver{

	@Override
	public void update(NodeManager nm, Object event) 
	{
		if( event instanceof LifecycleEvent )
		{
			LifecycleEvent lce = (LifecycleEvent) event;
			LifecycleOperation op = lce.getOperation();
			switch(op)
			{
				case CREATION:
				{
					nm.reportObjectCreation( lce.getObjectId(), lce.getEntityClass() );
					break;
				}
				case DESTRUCTION:
				{
					nm.reportObjectDestruction( lce.getObjectId() );
					break;
				}
				default:
				{
					//do nothing
					break;
				}
			}
		}
		
	}
	
}
